#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <stdio.h>

#include "uart_send.h"


void uart_send(struct comm_unit *msg) {
	ssize_t r = write(SERIAL_FD, msg, sizeof(struct comm_unit)+msg->size);

	printf("sent: %ld bytes\n", r);
	if (r == -1) {
		fprintf(stderr, "Send failed: %s\n", strerror(errno));
	}
}

void uart_recv(struct comm_unit * buff, uint16_t size) {
	ssize_t r = read(SERIAL_FD, buff, sizeof(struct comm_unit)+size);

	printf("recvd: %ld bytes\n", r);
	if (r == -1) {
		fprintf(stderr, "Recv failed: %s\n", strerror(errno));
	}
}

void sendInit() {
	return;
}
